package com.eastfair.pay.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 交易订单
 * </p>
 *
 * @author fwl
 * @date 2023-03-22
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "TransactionOrderOrderTypeEnum", description = "业务类型:#{CONTRACT:合同;SERVICE:服务;CERTIFICATE:证件;WORKEXTRA:加班;FINE:罚款;BOND:保证金;EXHIBITION:展览;MEETING:会议;FOOD:餐饮-枚举")
public enum TransactionOrderOrderTypeEnum implements BaseEnum {

    /**
     * CONTRACT="合同"
     */
    CONTRACT("合同"),
    /**
     * SERVICE="服务"
     */
    SERVICE("服务"),
    /**
     * CERTIFICATE="证件"
     */
    CERTIFICATE("证件"),
    /**
     * WORKEXTRA="加班"
     */
    WORKEXTRA("加班"),
    /**
     * FINE="罚款"
     */
    FINE("罚款"),
    /**
     * BOND="保证金"
     */
    BOND("保证金"),
    /**
     * EXHIBITION="展览"
     */
    EXHIBITION("展览"),
    /**
     * MEETING="会议"
     */
    MEETING("会议"),
    /**
     * FOOD="餐饮"
     */
    FOOD("餐饮"),

    /**
     * 结算单
     */
    SETTLEMENT("结算单"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static TransactionOrderOrderTypeEnum match(String val, TransactionOrderOrderTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static TransactionOrderOrderTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(TransactionOrderOrderTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "CONTRACT,SERVICE,CERTIFICATE,WORKEXTRA,FINE,BOND,EXHIBITION,MEETING,FOOD", example = "CONTRACT")
    public String getCode() {
        return this.name();
    }

}
